package day0414;

public class Test4 {
    public static double Sum(int n) {
        double sum = 0;
        double x = 2;
        double y = 1;
        for (int i = 0; i < n; i++) {
            sum += x / y;
            double temp = x;
            x = x + y;
            y = temp;
        }
        return sum;
    }

    public static void main(String[] args) {
        int n = 20;
        double result = Sum(n);
        System.out.println("该分数序列前 " + n + " 项之和为: " + result);
    }
}